package com.shijie.newvideo;

import android.text.TextUtils;

/**
 * @author zhangdunxiang
 * @date 2024/9/25
 * 功能：
 */
public class StringUtils {
    /**
     * 判断给定字符串是否空白串。 空白串是指由空格、制表符、回车符、换行符组成的字符串 若输入字符串为null或空字符串，返回true
     *
     * @param input
     * @return boolean
     */
    public static boolean isEmpty(String input) {
        if (input == null || "".equals(input)) return true;

        for (int i = 0; i < input.length(); i++) {
            char c = input.charAt(i);
            if (c != ' ' && c != '\t' && c != '\r' && c != '\n') {
                return false;
            }
        }
        return true;
    }

    public final static String httpUrlConvert(String httpUrl) {
        if (!TextUtils.isEmpty(httpUrl)) {
            if (httpUrl.startsWith("http") || httpUrl.startsWith("http:")) {
                return httpUrl;
            } else {
                if (httpUrl.startsWith("//")) {
                    return "https:" + httpUrl;
                } else {
                    return "https://" + httpUrl;
                }
            }
        } else {
            return "";
        }
    }
}
